#include <iostream>
#include <stdio.h>

using namespace std;

char a[3] = {'A','B','C'};

void f(int n,char a,char b,char c,int num){
    if(n == 1){
        cout << num << ' ' << a << " " << b << endl << endl;
    }
    else{
       f(n-1,a,c,b,num-1);
       cout << num << ' ' <<  a << " " << b << endl << endl;
       f(n-1,c,b,a,num-1);
    }
}

int main() {
    int n;
    cin >> n;
    f(n,a[0],a[1],a[2],n);
    return 0;
}